<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="./res/tui-editor.css">
    </link>
    <link rel="stylesheet" href="./res/tui-editor-contents.css">
    </link>
    <link rel="stylesheet" href="./res/codemirror.css">
    </link>
    <link rel="stylesheet" href="./res/github.min.css">
    </link>
    <script src="./res/tui-editor-Editor-full.js"></script>
    <script>
        window.onload = function(){
            new tui.Editor({
                el: document.body,
                height: '100%',
                //language:'zh_CN', //todo:会显示台湾的语言
                hideModeSwitch: true,
                initialEditType: 'markdown',
                previewStyle: 'vertical',
                usageStatistics: false,
                events: {
                    load: function (editor) {
                        window.editorMd = editor;
                        window.editorMd.setValue(self.articleContent);
                        setTimeout(() => {
                            self.needSave = false;
                        }, 86);
                    },
                    change: function () {
                        self.needSave = true;
                    }
                },
                hooks: {
                    addImageBlobHook: function (file, cb, source) {
                        self.imgSaveFileObj(file, (id, fullName, err) => {
                            let imgDom = '<img id="' + id + '" src="file://' + fullName + '" />';
                            window.editorMd.insertText(imgDom);
                            self.needSave = true;
                        })
                    }
                }
            });
        }
    </script>
</head>

<body>
</body>

</html>